package Java.Class.Game;

import java.util.HashMap;

//面向对象封装特性
public class Room {

    private HashMap<String, Room> hashMap = new HashMap<String, Room>();
    public String description;


    public Room(String description) {
        this.description = description;
    }

    //设置出口
    public void setExit(String dir, Room room) {
        hashMap.put(dir, room);
    }

    @Override
    public String toString() {
        return description;
    }

    //获取出口的方向
    public String getExitDesc() {
        StringBuilder sb = new StringBuilder();
        for (String dir : hashMap.keySet()) {
            sb.append(dir);
            sb.append(" ");
        }
        return sb.toString();
    }

    //获取出口的地方
    public Room getExit(String dir) {
        return hashMap.get(dir);
    }

}
